import type { Config } from 'jest';

const config: Config = {
  // preset: 'ts-jest',
  clearMocks: true,
  testEnvironment: 'jsdom',
  cacheDirectory: './jest/cache',
  collectCoverage: true,
  collectCoverageFrom: ['src/**/*', '!src/index.ts', '!**/__tests__/**', '!src/presets/index.ts', '!**/lynx/**'],
  coverageReporters: ['clover', 'json', 'lcov', 'cobertura'],
  coverageDirectory: './jest/coverage',
  resetMocks: true,
  resetModules: true,
  restoreMocks: true,
  testRegex: '/__tests__/.+\\.test\\.(t|j)sx?$',
  verbose: true,
  transform: { '^.+\\.(ts|tsx|js|jsx)?$': '@swc/jest' },
  transformIgnorePatterns: ['<rootDir>/node_modules/(?!(module-to-be-transformed)/)'],
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], // 模块文件扩展
  moduleNameMapper: {
    '^@/(.*)$': '<rootDir>/src/$1', // 将 @app/ 别名映射到 src/ 目录
  },
};

export default config;
